package com.blackitheima.test2;

import java.util.HashMap;
import java.util.Set;

public class MyHashMap1 {
    public static void main(String[] args) {
        //创建集合
        HashMap<Student,String> hm=new HashMap<>();
        hm.put(new Student("六小龄童",55),"中国");
        hm.put(new Student("齐天大圣",500),"花果山");
        hm.put(new Student("卡布达",18),"倭寇");
        hm.put(new Student("桂纶镁",18),"台湾");
        hm.put(new Student("桂纶镁",18),"台湾");
        //遍历集合
        hm.forEach(
                (Student key,String value)->{
                    System.out.println(key+"----"+value);
                }
        );
        //再一次遍历
        Set<Student> keys = hm.keySet();
        for (Student key : keys) {
            String value = hm.get(key);
            System.out.println(key.getName()+"--"+key.getAge()+"--"+value);
        }
    }
}
